// components/NavBar/NavBar.js
const app = getApp();
// const BaseURL = "http://cio.lvdengtech.com:9091/";
// const yyrequest = require("../../apis/modules/message")
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    titleName: String,
    isShowAvatar: {
      type: Boolean,
      default: false
    },
    isBack: {
      type: Boolean,
      default: false
    } ,
    isHome: {
      type: Boolean,
      default: false
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    statusBarHeight: "",
    avatarUrl: "", //头像地址
    openType: "getPhoneNumber",
    titleBarHeight:"",
    isTips:false
  },
  pageLifetimes: {
    show: function () {
      // 页面被展示
      let userInform = wx.getStorageSync("userInfo")
    
    this.setData({
     
      avatarUrl: userInform.avatarUrl ? userInform.avatarUrl : "/images/unLogin-avatar.png",
    })

    },
  },
  attached() {
    // let that = this;
    // let token = wx.getStorageSync("token");
    let userInform = wx.getStorageSync("userInfo");
    // let isToken = token?1:0
    // if(isToken==1){
    //  yyrequest.allMsg().then(res=>{
    //   for(var item of res.data){
    //     if(item.read==0){
    //      that.setData({
    //        isTips:true
    //      })
    //     break
    //     }
    //  }
    //     })
    // }
    this.setData({
      statusBarHeight: app.globalData.statusBarHeight,
      titleBarHeight:app.globalData.titleBarHeight,
      avatarUrl: userInform.avatarUrl ? userInform.avatarUrl : "/images/unLogin-avatar.png",
    })
    // if (token) {
    //   this.setData({
    //     openType: " "
    //   })
    // } else {
    //   this.setData({
    //     openType: "getUserInfo"
    //   })
    // }
  },

  /**
   * 组件的方法列表
   */
  methods: {
  goHome(){
    wx.redirectTo({
      url: '/pages/index/index',
    })
  },
    goBack() {
      wx.navigateBack()
    },
    goPersonCenter() {
      //可先判断是否授权！
      wx.navigateTo({
        url: '/pages/index/index',
      })
    }
  }
});